﻿IF EXISTS (SELECT * from sys.procedures p left join sys.schemas s on p.schema_id = s.schema_id where p.name='reference_select_by_zohocrm' and s.name='Meta')
DROP PROCEDURE [Meta].reference_select_by_zohocrm
GO
CREATE PROCEDURE [Meta].reference_select_by_zohocrm 
@ZohoCRM int
AS
BEGIN
SELECT 	
	[References].[id_reference] AS [PK],
	[References].[last_update] AS [LastUpdate],
	[References].[Google] AS [Google],
	[References].[Google_last_update] AS [GoogleLastUpdate],
	[References].[ZohoCRM] AS [ZohoCRM],
	[References].[ZohoCRM_last_update] AS [ZohoCRMLastUpdate],
	[References].[from] AS [From],
	[References].[Validated] AS [Validated]
FROM 
	[References] 
WHERE
	[References].[ZohoCRM] = @ZohoCRM 
END